<?php

class Ext_Avatar_Show_Build
{
    protected $_imageFilePath;
    protected $_imageFileName;
    
    public function __construct($userId)
    {
        $_appModelDbTableUserAvatar = App_Model_DbTable_User_Avatar::getInstance();
        $_avatarRow = $_appModelDbTableUserAvatar->getRowByUserId($userId);
        
        $_appModelDbTableImage = App_Model_DbTable_Image::getInstance();
        $imageRow = $_appModelDbTableImage->getRowById($_avatarRow['imageId']);

        $_path = $imageRow['path'];
        if (substr(PHP_OS, 0, 3) == 'WIN')
        {
            $_path = str_replace(DIRECTORY_SEPARATOR, '/', $_path);
        }
        $this->_imageFilePath = rtrim($_path, '/') . '/';
        $this->_imageFileName = $imageRow['name'];
    }
    
    public function url($sizeName)
    {
        $_imageUrl  = rtrim($this->_config['url'], "/") . "/avatar/" . $sizeName . "/" . $this->_imageFilePath . $this->_imageFileName;
        return $_imageUrl;    
    }
}
